//
// Created by 王乐 on 2022/2/7.
//

#ifndef LESTE_LESPRITERENDERER_H
#define LESTE_LESPRITERENDERER_H

#include "LeRenderer.h"
#include <string>
#include <map>

struct SpriteSheet
{
    SpriteSheet(){}
    SpriteSheet(const char *diffuseMapPath, unsigned int numSprites, float spriteChangeTime);

    const char* diffuseMapPath;
    unsigned int numSprites;
    float spriteChangeTime;
};

class LeSpriteRenderer : public LeRenderer
{
public:
    LeSpriteRenderer();
    virtual ~LeSpriteRenderer();

    void preLoopRender() override;

    void render() override;

    void postLoopRender() override;


    bool changeSpriteSheet(const std::string &name);

    void addSpriteSheet(const std::string &name, SpriteSheet spritesheet);

    void setFlipX(bool flipx);

private:
    std::map<std::string, SpriteSheet> m_MapSpriteSheets;
    std::map<std::string, unsigned int> m_MapDiffuseMaps;
    std::string m_CurSpriteSheetName;

    unsigned int m_CurSpriteIndex;
    float m_CurSpriteChangeTime;

    bool m_bFlipX;
};


#endif //LESTE_LESPRITERENDERER_H
